package com.nyist.myticket.web.controller;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.nyist.myticket.biz.entity.dto.FaceDto;
import com.nyist.myticket.biz.entity.vo.FaceVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yangxiaogen
 * @date 2021/1/21 16:38
 */
@RestController
@RequestMapping("/api/v1")
@Slf4j
public class FaceController {

    @PostMapping("/record/face")
    public FaceVo postDataSucess(@RequestBody String str){
        log.info("照片",str);
        FaceDto faceDto = new FaceDto();
        System.out.println(faceDto);
        return null;
    }

    /*@PostMapping("/stranger")
    public FaceOut postDataFail(@RequestBody FaceIn face){
        log.info("照片",face.getPhoto());
        FaceIn faceIn = new FaceIn();
        System.out.println(faceIn);
        return null;
    }*/

    @PostMapping("/stranger")
    public FaceVo postDataFail(@RequestBody String str){
        JSONObject jsonObject = JSONObject.parseObject(str);
        String sn = jsonObject.getString("sn");
//        JSONObject jsonObjectJSONObject = jsonObject.getJSONObject("logs");
        JSONArray jsonArray = jsonObject.getJSONArray("logs");
        JSONObject arrayJSONObject = jsonArray.getJSONObject(0);
        System.out.println("------------"+arrayJSONObject.toString());
        log.info("照片",str);
        FaceDto faceDto = new FaceDto();
        System.out.println(faceDto);
        return null;
    }

}
